package com.codingfuture.erp_system.service.impl;

import com.codingfuture.erp_system.entity.GoodsType;
import com.codingfuture.erp_system.mapper.GoodsTypeMapper;
import com.codingfuture.erp_system.service.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GoodsTypeServiceImpl implements GoodsTypeService {

    @Autowired
    private GoodsTypeMapper goodsTypeMapper;

    @Override
    public GoodsType findById(Integer id) {
        return goodsTypeMapper.findById(id);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean insert(GoodsType goodsType) {
        return goodsTypeMapper.insert(goodsType) != 0;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean delete(Integer id) {
        return goodsTypeMapper.delete(id) != 0;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean update(GoodsType goodsType) {
        return goodsTypeMapper.update(goodsType) != 0;
    }

    @Override
    public List<GoodsType> findByAll(String name) {
        return goodsTypeMapper.findByAll(name);
    }

    @Override
    public GoodsType findByName(String name) {
        return goodsTypeMapper.findByName(name);
    }

}
